package com.lc.zpyh.ui.activity.supermarket;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lc.zpyh.R;
import com.lc.zpyh.app.AppActivity;
import com.lc.zpyh.manager.ActivityManager;
import com.lc.zpyh.ui.activity.MainActivity;
import com.lc.zpyh.util.constant.EvenConstant;
import com.lc.zpyh.util.eventbus.Event;
import com.lc.zpyh.util.eventbus.EventBusUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PayStautsActivity extends AppActivity {
    @BindView(R.id.img_pay_type)
    ImageView imgPayType;
    @BindView(R.id.tv_shibai_sure)
    TextView tvShibaiSure;
    @BindView(R.id.tv_chenggong_tohome)
    TextView tvChenggongTohome;
    @BindView(R.id.tv_chenggong_to_order)
    TextView tvChenggongToOrder;
    @BindView(R.id.ll_pay_success)
    LinearLayout llPaySuccess;
    @BindView(R.id.tv_type)
    TextView tvType;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_pay_stauts;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        if (getIntent().getStringExtra("type") != null) {
            if (getIntent().getStringExtra("type").equals("失败")) {
                imgPayType.setImageResource(R.mipmap.pay_shibai);
                tvType.setText("支付失败");
            }
        }


    }

    @OnClick({R.id.tv_shibai_sure, R.id.tv_chenggong_tohome, R.id.tv_chenggong_to_order})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_shibai_sure:
                break;
            case R.id.tv_chenggong_tohome:
                // 进行内存优化，销毁除登录页之外的所有界面
                ActivityManager.getInstance().finishAllActivities(MainActivity.class);
                startActivity(MainActivity.class);
                break;
            case R.id.tv_chenggong_to_order:
//                ActivityManager.getInstance().finishAllActivities(MainActivity.class);
                finish();
                EventBusUtils.sendEvent(new Event(EvenConstant.PAYSTAUTS));
//                ActivityManager.getInstance().finishAllActivities(MainActivity.class);
                break;
        }
    }
}
